package com.icode.core.dto.user;

import com.icode.core.model.user.District;

import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: xianfei
 * Date: 15-4-7
 * Time: 上午10:37
 * To change this template use File | Settings | File Templates.
 */
public class DistrictDTO {

    private String id;
    private String districtName;
    private String cityId;

    public DistrictDTO() {
    }

    public DistrictDTO(String id, String districtName, String cityId) {
        this.id = id;
        this.districtName = districtName;
        this.cityId = cityId;
    }

    public static DistrictDTO toDTO(District district) {
        return new DistrictDTO(String.valueOf(district.id()), district.name(), String.valueOf(district.city().id()));
    }

    public static List<DistrictDTO> toDTOs(List<District> districts) {
        List<DistrictDTO> districtDTOs = new ArrayList<>();
        for (District d : districts) {
            DistrictDTO districtDTO = toDTO(d);
            districtDTOs.add(districtDTO);
        }
        return districtDTOs;
    }

    public void setId(String id) {
        this.id = id;
    }

    public void setDistrictName(String districtName) {
        this.districtName = districtName;
    }

    public void setCityId(String cityId) {
        this.cityId = cityId;
    }

    public String getId() {

        return id;
    }

    public String getDistrictName() {
        return districtName;
    }

    public String getCityId() {
        return cityId;
    }
}
